package org.firebug.metadata.api.controller;

import org.firebug.common.bean.api.Meta;
import org.firebug.common.bean.api.Response;
import org.firebug.metadata.client.feign.RegionFeign;
import org.firebug.metadata.client.vo.RegionVO;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 地区服务
 */
@RestController
@RequestMapping(value = "/region")
public class RegionController {
    @Resource
    private RegionFeign regionFeign;

    @RequestMapping(value = "/query/{code}", method = {RequestMethod.GET})
    public Response<RegionVO> query(@PathVariable String code) {
        return Response.newInstance(Meta._200, regionFeign.query(code));
    }

    @RequestMapping(value = "/list/{code}", method = {RequestMethod.GET})
    public Response<List<RegionVO>> list(@PathVariable("code") String code) {
        return Response.newInstance(Meta._200, regionFeign.list(code));
    }

}